<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <title>登录成功</title>
</head>

<body>
<div id="app">
    <h1>欢迎 {{name}} 登录成功~~</h1>
    <h1>
        token:
        <span style="color: forestgreen">{{token}}</span>
    </h1>
</div>

</body>
<script>
    new Vue({
        el: '#app',
        data: {
            token: '',
            name: ''
        },
        mounted: function () {

            this.token = this.getData("token");
            //只需要转一次码
            this.name = decodeURI(this.getData("name"));
        },
        methods: {
            getData: function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数

                if (r != null) return unescape(r[2]);
                window.location.href = "login"
                // return null; //返回参数值
            }
        }
    })
    ;
</script>
</html>